package com.xmy.cultivate.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xmy.cultivate.entity.RadeFiducialSet;
import com.xmy.cultivate.service.IRadeFiducialSetService;
import com.xmy.cultivate.util.Code;
import com.xmy.cultivate.util.Result;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 需要统计基准值的率 前端控制器
 * </p>
 *
 * @author hpiggy
 * @since 2025-04-28
 */
@RestController
@RequestMapping("/api/admin/radeFiducialSet")
public class RadeFiducialSetController extends BaseController{

    @Autowired
    IRadeFiducialSetService iRadeFiducialSetService;

    /**
     * 获取项目名称
     * @param yearPart
     * @param quarterNum
     * @return
     */
    @GetMapping("/getProjectsName")
    public Result getProjectsName(@RequestParam(value = "yearPart", defaultValue = "") String yearPart,
                                 @RequestParam(value = "quarterNum", defaultValue = "") String quarterNum) {

        QueryWrapper<RadeFiducialSet> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotBlank(yearPart),"year_part", yearPart);
        queryWrapper.eq(StringUtils.isNotBlank(quarterNum),"quarter_num", quarterNum);
        queryWrapper.eq("status", 1);
        List<RadeFiducialSet> list = iRadeFiducialSetService.list(queryWrapper);
        return new Result(Code.OK, list, Code.GET_OK_MSG);
    }

}
